﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Linq;
using System.Data.Linq.Mapping;

namespace Inbox.Domain
{
    [global::System.Data.Linq.Mapping.TableAttribute(Name = "dbo.Machine_Equipment")]
    public class Machine_Equipment : PersistentObject
    {
        #region **Private**

        private Guid? _Machine_ID, _Equipment_ID;

        #endregion

        [Column(Storage = "_Machine_ID", DbType = "UniqueIdentifier")]
        public Guid? Machine_ID
        {
            get { return this._Machine_ID; }
            set { this._Machine_ID = value; }
        }

        [Column(Storage = "_Equipment_ID", DbType = "UniqueIdentifier")]
        public Guid? Equipment_ID
        {
            get { return this._Equipment_ID; }
            set { this._Equipment_ID = value; }
        }

        private EntityRef<Machine> _MachineRef;
        [Association(Name = "Machine_Machine_Equipment", Storage = "Machine", ThisKey = "Machine_ID", OtherKey = "ID", IsForeignKey = true)]
        public Machine Machine
        {
            get
            {
                return this._MachineRef.Entity;
            }
            set
            {
                if (value != null)
                    this.Machine_ID = value.ID;
                else
                    this.Machine_ID = Guid.Empty;
            }
        }

        private EntityRef<Equipment> _EquipmentRef;
        [Association(Name = "Equipment_Machine_Equipment", Storage = "Equipment", ThisKey = "Equipment_ID", OtherKey = "ID", IsForeignKey = true)]
        public Equipment Equipment
        {
            get
            {
                return this._EquipmentRef.Entity;
            }
            set
            {
                if (value != null)
                    this.Equipment_ID = value.ID;
                else
                    this.Equipment_ID = Guid.Empty;
            }
        }

        public Machine_Equipment()
        {
            this._MachineRef = new EntityRef<Machine>();
            this._EquipmentRef = new EntityRef<Equipment>();
        }
    }
}
